package com.woniuxy.dynamic.client;

import com.woniuxy.dynamic.cglib.CgliDynamic;
import com.woniuxy.dynamic.service.UserService;
import com.woniuxy.dynamic.service.impl.UserServcieImpl;

/**
 * @author 佘赛飞
 * @create 2021 -11 -15 7:11 PM
 */
public class TestProxy {
    public static void main(String[] args) {
        //必须经过我代理方法的摧残以后 才能有代理后的对象 因为是我们自己手写的所以需要new
        //如果是进入了aop的环节，将由配置文件来实现这个动态代理的配置
        /*JdkDynamic jdkDynamic = new JdkDynamic();
        UserServcieImpl userServcie = new UserServcieImpl();
        UserService proxyObject = (UserService) jdkDynamic.getProxyObject(userServcie);*/

        //new Cglib代理
        UserServcieImpl userServcie1 = new UserServcieImpl();
        CgliDynamic cgliDynamic = new CgliDynamic();
        UserService proxyObject = (UserService) cgliDynamic.getProxyObject(userServcie1);
        proxyObject.addOne();
        proxyObject.deleteOn();
    }
}
